minetest.register_node("lunorecipes:ampoule", {
	description = "Ampola Vazia",
	drawtype = "plantlike",
	tiles = {"tex_frasco_vazio.png"},
	inventory_image = "obj_frasco_vazio.png",
	wield_image = "obj_frasco_vazio.png",
	paramtype = "light",
	liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Ampola Vazia")
	end,
	on_use = function(itemstack, user, pointed_thing)
		if pointed_thing.under~=nil then
			local node = minetest.get_node(pointed_thing.under)
			--minetest.chat_send_player(user:get_player_name(), "Voce esta apontando para '".. node.name .."'!")
			if node.name == "default:water_source" or node.name == "default:water_flowing" then
				user:get_inventory():add_item("main", ItemStack("lunorecipes:ampoule_with_water"))
				minetest.sound_play("sfx_water", {
					pos=user:getpos(),
					gain = 6.0,
					max_hear_distance = 5,
				})
				itemstack:take_item()
			else
				minetest.chat_send_player(user:get_player_name(), "Voce nao pode coletar isto com este item.")
			end
			return itemstack
		end
	end,
	
})

minetest.register_craft({
	output = "lunorecipes:ampoule",
	recipe = {
		{"default:glass",	"group:wood",		"default:glass"},
		{"default:glass",	"",					"default:glass"},
		{"",					"default:glass",	""},
	},
})

minetest.register_craft({
	output = "lunorecipes:ampoule",
	recipe = {
		{"default:wood"},
		{"vessels:glass_bottle"},
	},
})


minetest.register_alias("ampoule", "lunorecipes:ampoule")
minetest.register_alias("ampola", "lunorecipes:ampoule")

--#############################################################################################################

minetest.register_node("lunorecipes:ampoule_with_water", {
	description = "Ampola com agua (p/ Pocoes)",
	drawtype = "plantlike",
	tiles = {"tex_frasco_cheio_azul_ciano.png"},
	inventory_image = "obj_frasco_cheio_azul_ciano.png",
	wield_image = "obj_frasco_cheio_azul_ciano.png",
	paramtype = "light",
	liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Ampola com agua (p/ Pocoes)")
	end,
	on_use = function(itemstack, user, pointed_thing)
		user:get_inventory():add_item("main", ItemStack("lunorecipes:ampoule"))
		itemstack:take_item()
		return itemstack
	end,
})

minetest.register_alias("ampoulewithwater", "lunorecipes:ampoule_with_water")
minetest.register_alias("ampolacomagua", "lunorecipes:ampoule_with_water")


--#############################################################################################################

minetest.register_craft({
	output = "lunorecipes:ampoule_with_misc", --Falta cozinhar para tornar uma pocao. (sem cozinhar e mortal)
	recipe = {
		{"lunorecipes:magicdust"},
		{"default:apple"},
		{"lunorecipes:ampoule_with_water"},
	},
	--sounds = "sound_healing",
})

minetest.register_node("lunorecipes:ampoule_with_misc", {
	description = "Pocao de Lunovox (Nao-Cozida)",
	drawtype = "plantlike",
	tiles = {"tex_frasco_cheio_verde1.png"},
	inventory_image = "obj_frasco_cheio_verde1.png",
	wield_image = "obj_frasco_cheio_verde1.png",
	paramtype = "light",
	--liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1,eatable=1,meat=2},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Pocao de Lunovox (Nao-Cozida)")
	end,
	on_use = function(itemstack, user, pointed_thing)
		return lunorecipes.doEat(user, itemstack, -20, 0, "sound_healing", "lunorecipes:ampoule")
	end,
})

minetest.register_craft({
	type = "cooking",
	output = "lunorecipes:ampoule_with_lunopotion",
	recipe = "lunorecipes:ampoule_with_misc",
	cooktime = 5,
})

minetest.register_alias("ampoulewithmisc", "lunorecipes:ampoule_with_misc")
minetest.register_alias("ampolacommistura", "lunorecipes:ampoule_with_misc")

--#############################################################################################################

minetest.register_node("lunorecipes:ampoule_with_lunopotion", {
	description = "Pocao de Lunovox (HP+100%)",
	drawtype = "plantlike",
	tiles = {"tex_frasco_cheio_verde2.png"},
	inventory_image = "obj_frasco_cheio_verde2.png",
	wield_image = "obj_frasco_cheio_verde2.png",
	paramtype = "light",
	--liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1,eatable=1,meat=2},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Pocao de Lunovox (HP+10, SP+2)")
	end,
	on_use = function(itemstack, user, pointed_thing)
		return lunorecipes.doEat(user, itemstack, 20, 4, "sound_healing", "lunorecipes:ampoule")
	end,
})

minetest.register_alias("hppotion"			, "lunorecipes:ampoule_with_lunopotion")
minetest.register_alias("lunopotion"		, "lunorecipes:ampoule_with_lunopotion")
minetest.register_alias("pocaodehp"			, "lunorecipes:ampoule_with_lunopotion")
minetest.register_alias("pocaodeluno"		, "lunorecipes:ampoule_with_lunopotion")
minetest.register_alias("pocaodelunovox"	, "lunorecipes:ampoule_with_lunopotion")

--#############################################################################################################

minetest.register_node("lunorecipes:ampoule_with_xp_raw", {
	description = "Pocao de Experiencia (Nao-Cozida)",
	drawtype = "plantlike",
	tiles = {"tex_frasco_cheio_amarelo1.png"},
	inventory_image = "obj_frasco_cheio_amarelo1.png",
	wield_image = "obj_frasco_cheio_amarelo1.png",
	paramtype = "light",
	--liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1,eatable=1,meat=2},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Pocao de Experiencia (Nao-Cozida)")
	end,
	on_use = function(itemstack, user, pointed_thing)
		return lunorecipes.doEat(user, itemstack, -20, 0, "sound_healing", "lunorecipes:ampoule") --Falta cozinhar para tornar uma pocao. (sem cozinhar e mortal)
	end,
})

minetest.register_alias("ampoulewithxpraw"	, "lunorecipes:ampoule_with_xp_raw")
minetest.register_alias("ampolacomxpcrua"		, "lunorecipes:ampoule_with_xp_raw")
minetest.register_alias("ampoladexpcrua"		, "lunorecipes:ampoule_with_xp_raw")


--[[
minetest.register_craft({
	output = "lunorecipes:ampoule_with_xp_raw",
	recipe = {
		--{"lunorecipes:magicdust"	, ""											, "lunorecipes:magicdust"},
		{"lunorecipes:dust_gold"	, "lunorecipes:dust_gold"				, "lunorecipes:dust_gold"},
		{"lunorecipes:magicdust"	, "lunorecipes:ampoule_with_water"	, "lunorecipes:magicdust"},
	},
})
]]--


minetest.register_node("lunorecipes:ampoule_with_xp", {
	description = "Pocao de Experiencia (XP+10%)",
	drawtype = "plantlike",
	tiles = {"tex_frasco_cheio_amarelo2.png"},
	inventory_image = "obj_frasco_cheio_amarelo2.png",
	wield_image = "obj_frasco_cheio_amarelo2.png",
	paramtype = "light",
	--liquids_pointable = true, -- Pode apontar para node de Liquidos (mais tarde podera coletar agua)
	stack_max=99, --Acumula 6 por slot
	walkable = false,
	selection_box = {
		type = "fixed",
		fixed = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25}
	},
	--groups = {vessel=1,dig_immediate=3,attached_node=1},
	groups = {vessel=1,dig_immediate=3,attached_node=1,eatable=1,meat=2},
	sounds = default.node_sound_glass_defaults(),
	after_place_node = function(pos, placer)
		local meta = minetest.get_meta(pos)
		--meta:set_string("owner", placer:get_player_name() or "")
		meta:set_string("infotext", "Pocao de Experiencia (XP+10%)")
	end,
	on_use = function(itemstack, user, pointed_thing)
		lunomods.givePercentXP(user, 10, nil) --aumenta 10% de XP do nivel atual

		if not minetest.setting_getbool("creative_mode") then 
			itemstack:take_item()
			user:get_inventory():add_item("main", ItemStack("lunorecipes:ampoule"))
		end
		return itemstack
	end,
})

minetest.register_alias("ampoulewithxp"	, "lunorecipes:ampoule_with_xp")
minetest.register_alias("ampolacomxp"	, "lunorecipes:ampoule_with_xp")
minetest.register_alias("ampoladexp"	, "lunorecipes:ampoule_with_xp")
minetest.register_alias("xppotion"		, "lunorecipes:ampoule_with_xp")
minetest.register_alias("pocaocomxp"	, "lunorecipes:ampoule_with_xp")
minetest.register_alias("pocaodexp"		, "lunorecipes:ampoule_with_xp")

minetest.register_craft({
	type = "cooking",
	output = "lunorecipes:ampoule_with_xp",
	recipe = "lunorecipes:ampoule_with_xp_raw",
	cooktime = 5,
})


